package com.norseman.demo.controller;

import com.norseman.demo.service.model.*;
import com.norseman.demo.service.model.*;

import java.sql.Timestamp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/restfulservice/liveMedia")
public class LiveMediaController {

	@Autowired
	AthleteLiveMediaServiceImp athleteLiveMediaService;
	@Autowired
	SupportLiveMediaServiceImp supportLiveMediaService;

	@RequestMapping(value = "/athlete", method = RequestMethod.POST)
	@ResponseBody
	public LiveMediaFeed updateLiveMediaFeed(
			@RequestParam("userId") int userId,
			@RequestParam("athleteId") int athleteId,
			@RequestParam("lat") double lat, @RequestParam("lng") double lng,
			@RequestParam("height") double height,
			@RequestParam("speed") double speed) throws Exception {
		return athleteLiveMediaService.updateLiveMediaFeed(userId, athleteId,
				lat, lng, height, speed);
	}

	@RequestMapping(value = "/support", method = RequestMethod.POST)
	@ResponseBody
	public LiveMediaFeed updateLiveMediaFeed(
			@RequestParam("userId") int userId,
			@RequestParam("supportId") int supportId,
			@RequestParam("lat") double lat, @RequestParam("lng") double lng,
			@RequestParam("height") double height,
			@RequestParam("speed") double speed) throws Exception {
		return supportLiveMediaService.updateLiveMediaFeed(userId, supportId,
				lat, lng, height, speed);
	}

}
